﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;

namespace badminton.DynamicData.FieldTemplates
{
    public partial class Image : System.Web.DynamicData.FieldTemplateUserControl
    {
        protected HyperLink HyperLink1;

        public override Control DataControl
        {
            get
            {
                return HyperLink1;
            }
        }

        public string GetFileName(string str)
        {
            str = str.Trim();
            if (str.Length==0)
            {
                return str;
            }
            int idx = str.LastIndexOf('\\');
            if (idx == -1) idx = str.LastIndexOf('/');

            if (idx == -1) return str;

            return str.Substring(idx+1);

        }

        public string GetLink(string str)
        {
            string fn = GetFileName(str);
            if (fn.Length == 0) return "";

            return @"~\DynamicData\images\" + fn;
        }

    }
}
